/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/


#include "flex测试.h"



#include "物理引擎测试.h"

#include "面/几何模型生成.h"

#include "../A_引擎/引擎.h"
#include <文件/file_载入保存数据.h>
#include <随机数.h>


#include "物理/物理.h"
#include "物体/物体.h"








void f_test_FleX() {
	vec3 boxSize = { 2.0, 2.0, 2.0 };

	E_物理引擎 物理引擎 = E_物理引擎::E_物理引擎_FleX;

	S_线管创建配置 配置 = {
		{
			{0, E_着色阶段::e_顶点着色, E_板载缓存类型::e_UBO},
			{1, E_着色阶段::e_顶点着色, E_板载缓存类型::e_SSBO}
		},
		{
			{0,sizeof(vec3),0,E_数据格式::e_F_RGB},
			{1,sizeof(vec3),0,E_数据格式::e_F_RGB},
		},
		{
			{"D:/U/Project/engine/资产/着色/vert点绘制粒子.spv", E_着色阶段::e_顶点着色},
			{"D:/U/Project/engine/资产/着色/frag纯色面绘制.spv", E_着色阶段::e_像素着色},
		}
	};

	S_线管创建参数 线管参数({ 1024, 576 });
	线管参数.m_绘制方式 = E_绘制方式::e_画点集;
	线管参数.m_填充模式 = E_填充模式::e_填充点;
	auto* 粒子着色 = f_create着色(S_框架::ctx, 配置);
	auto* 粒子线管 = f_create线管(S_框架::ctx, *粒子着色, 线管参数);

	auto* 粒子材质 = f_create基本材质(E_基本材质类型::e_单色材质, "a");
	粒子材质->m_Shader = 粒子着色;
	粒子材质->m_Pipeline = 粒子线管;



	S_物体* psys = f_ob_创建物体(E_物体类型::t_粒子, 0, S_框架::ctx);
	f_set粒子数量(psys, 1000000);
	f_ob_set材质(psys, 粒子材质);
	f_scene_场景链接物体(S_框架::g_Scene, psys);




	std::vector<vec3> p;
	f_随机向量(p, 1000000, { -20.0, 20.0 }, 10, { 1.0f, 1.0f, 1.0f });
	f_set粒子位置(psys, p.data(), p.size());





	


	auto* 材质 = f_创建材质(&S_框架::g_Scene->m_Physics, 0.5, 0.5, 0.5, 物理引擎);
	S_Tranform t;
	auto* boxGem = f_创建方体几何体(&S_框架::g_Scene->m_Physics, boxSize, 物理引擎);
	auto* phy流体粒子 = f_create流体粒子(&S_框架::g_Scene->m_Physics, *材质, t, 100000, 物理引擎);
	
	f_物理体添加到引擎(&S_框架::g_Scene->m_Physics, phy流体粒子, 0, 物理引擎);

	return;


	auto* 物体Box = f_创建BOX物体(boxSize, S_框架::ctx);
	f_ob_set材质(物体Box, S_框架::g_索引绘制材质);
	S_框架::g_Scene->m_物体.push_back(物体Box);




	
	

	
	auto* boxR = f_创建刚体(&S_框架::g_Scene->m_Physics, *boxGem, *材质, t);

	f_物理体添加到引擎(&S_框架::g_Scene->m_Physics, boxR, 0, 物理引擎);




}









